//
//  DetailforActThirdVC.m
//  XDCommonApp
//
//  Created by xindaoapp on 14-3-10.
//  Copyright (c) 2014年 XD-XY. All rights reserved.
//

#import "DetailforActThirdVC.h"
#import "XDTools.h"
#import "WaterDetailViewController.h"
#import "XDHeader.h"
#import "UIImageView+WebCache.h"
#import "DetailOrgnizerCell.h"

#define dHeightForHeader 0.0

@interface DetailforActThirdVC ()

{
    NSString *artNameStr;
    NSString *activeDesign;
    NSString *activityIntroduce;
    NSString *activityPosition;
    NSString *activitySponsor;// 主办
    NSString *activityTime;
    NSString *activityTitle;
    NSString *organizer;//
    NSString *activityUndertake;
    NSString *activityScanTime;//浏览次数
    NSString *exhibitWorkCount;// 参展数量
    NSArray *actArray;
    NSString *activityUrl;
    float varHeight;
    UILabel *contLabel;
    UIImageView *arrowIV;
    BOOL isClicked;

    UILabel *posLb;
}

@end

@implementation DetailforActThirdVC

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
//    [self initWidget];
    activityTitle = @"";
    activityTime = @"";
    artNameStr = @"";
    activitySponsor = @"";
    activeDesign = @"";
    activityPosition = @"";
    activityIntroduce = @"";
    exhibitWorkCount = @"";
    activityScanTime = @"";
    activityUndertake = @"";
    activityUrl = @"";
    isClicked = NO;
    
    [self getXmlData];
}

- (void)initWidget
{
    self.titleLabel.text = @"活动详情";
    self.titleLabel.font = [UIFont boldSystemFontOfSize:17];
    self.titleLabel.textColor = TEXTBLACKCOLORE;
    
    self.shareView = [[XDShareView alloc] initWithFrame:CGRectMake(0, UI_STATUS_BAR_HEIGHT, UI_SCREEN_WIDTH, UI_SCREEN_HEIGHT)];
    _shareView.delegate = self;
    _shareView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:_shareView];
    _shareView.hidden =YES;
    
    self.detailActTableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0, UI_SCREEN_WIDTH,self.contentView.frame.size.height) style:UITableViewStylePlain];
    _detailActTableView.delegate = self;
    _detailActTableView.dataSource = self;
    _detailActTableView.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:_detailActTableView];
}

#pragma mark  --------------tableView delegate----------------

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
//    if (section == 0||section==1){
//        return 1;
//    }
    return 1;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    
    return 3;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section==0) {
        return 0;
    }
    if (section==1) {
        return 40;
    }
    return dHeightForHeader;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    NSArray * array;
    CGFloat headerHeight=0;
    if (tableView == _detailActTableView){
        
        array=@[@"0",@"活动介绍",@"参展机构"];
        headerHeight = dHeightForHeader;
        if (section==1) {
            headerHeight = 40;
        }
    }
    UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, headerHeight)];
//    view.backgroundColor = RGBA(217, 217, 217, 1);
    view.backgroundColor = RGBA(242, 242, 242, 1);
    UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, UI_SCREEN_WIDTH-15, headerHeight)];
    label.textColor = TEXTBLACKCOLORE;
    label.font = [UIFont systemFontOfSize:15];
    label.backgroundColor = [UIColor clearColor];
    label.text = [array objectAtIndex:section];
    [view addSubview:label];
    return view;
    
}


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    if (indexPath.section == 0){
        if (indexPath.row == 0){
            return 461/2.0f+20/2.0f+3/2.0f-18;
        }
        return 461/2.0f+10/2.0f;
    }else if(indexPath.section==1){
//        if (indexPath.row == 0){
//            return 20/2.0f+82/2.0f+10;
//        }
        if (!isClicked) {
            return 120;
        }
//        return 20/2.0f+82/2.0f;
        return varHeight;
        
    }else {
        
        return 60.0f;
        
    }
}


-(UITableViewCell * )tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(tableView == _detailActTableView){
        static NSString * cellName = @"cell";
        UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellName];
        if (cell == nil){
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
            cell.backgroundColor = [UIColor clearColor];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
//        tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

        if (indexPath.section == 0) {
            UIFont *actFont = [UIFont boldSystemFontOfSize:15];
            if (!actNameLb) {
                actNameLb = [[UILabel alloc]init];
                actNameLb.frame = CGRectMake(15, 10,UI_SCREEN_WIDTH, 0);
                actNameLb.font = actFont;
                actNameLb.numberOfLines = 0;
                actNameLb.backgroundColor = [UIColor clearColor];
                CGSize size = CGSizeMake(300, 200.0f);
                NSString *str = activityTitle;//@"鲁本斯、凡戴克与佛兰德斯画派——列支敦士登王室珍藏展";
                size = [str sizeWithFont:actFont constrainedToSize:CGSizeMake(actNameLb.frame.size.width, MAXFLOAT) lineBreakMode:NSLineBreakByWordWrapping];
                //根据计算结果重新设置label的尺寸
                [actNameLb setFrame:CGRectMake(15, 10, UI_SCREEN_WIDTH-30, size.height)];
                actNameLb.text = str;
                [cell.contentView addSubview:actNameLb];

                actImgV = [[UIImageView alloc]initWithFrame:CGRectMake(actNameLb.frame.origin.x, height_y(actNameLb)+10, 90, 130)];
                actImgV.backgroundColor = UIColorFromRGB(0xdbdada);
                NSString * imageUrl = [NSString stringWithFormat:@"%@%@",ImageMainUrl,activityUrl];
                NSString * urlstring = [imageUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
                //            actImgV.tag = 200;
                [actImgV setImageWithURL:[NSURL URLWithString:urlstring] placeholderImage:[UIImage imageNamed:@"placehold_image"]];
                
                [cell.contentView addSubview:actImgV];
            }

            if (!timeLabel) {
                UIImageView *pointIV = [[UIImageView alloc]initWithFrame:CGRectMake(width_x(actImgV)+10, actImgV.frame.origin.y+5.5, 9, 9)];
                pointIV.image = [UIImage imageNamed:@"activity_time"];
                [cell.contentView addSubview:pointIV];//  时间点

                timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(width_x(actImgV)+24, actImgV.frame.origin.y, 176, 20)];
                timeLabel.backgroundColor = [UIColor clearColor];
                timeLabel.text = [NSString stringWithFormat:@"时间: %@",activityTime];//@"时间: 2014/02/22-2014/04/18";
                timeLabel.font = [UIFont systemFontOfSize:12];
                timeLabel.textColor = TEXTBLACKCOLORE4;
                [cell.contentView addSubview:timeLabel];
            }

            if (!posLb) {

                UIImageView *pointIV = [[UIImageView alloc]initWithFrame:CGRectMake(width_x(actImgV)+10, height_y(timeLabel)+5, 7, 10)];
                pointIV.image = [UIImage imageNamed:@"activity_position"];
                [cell.contentView addSubview:pointIV];//
                
                posLb = [[UILabel alloc ]initWithFrame:CGRectMake(timeLabel.frame.origin.x, height_y(timeLabel), 33, timeLabel.frame.size.height)];
                posLb.backgroundColor = [UIColor clearColor];
                posLb.text = @"位置: ";
                posLb.textColor = TEXTBLACKCOLORE4;
                posLb.font = timeLabel.font;
                [cell.contentView addSubview:posLb];

            }
            if (!positionLabel) {
                positionLabel = [[UILabel alloc]initWithFrame:CGRectMake(width_x(posLb), posLb.frame.origin.y+10, 140, 30)];
                positionLabel.backgroundColor = [UIColor clearColor];
                positionLabel.numberOfLines = 0;
                positionLabel.textColor = TEXTBLACKCOLORE4;
                positionLabel.font = timeLabel.font;

                CGSize Psize = CGSizeMake(140, 2000.0f);
                NSString *Pstr = activityPosition;//@"北京  朝阳  尤伦斯当代\n艺术中心  UCCA 甬道、\n长廊";//activityPosition;//
                Psize = [Pstr sizeWithFont:posLb.font constrainedToSize:CGSizeMake(positionLabel.frame.size.width, MAXFLOAT) lineBreakMode:NSLineBreakByWordWrapping];

                NSAttributedString *attributedString =[[NSAttributedString alloc] initWithString:Pstr attributes:@{NSKernAttributeName : @(5.0f)}];
                [positionLabel setAttributedText:attributedString];
                positionLabel.text = Pstr;
                //根据计算结果重新设置label的尺寸
                [positionLabel setFrame:CGRectMake(width_x(posLb), posLb.frame.origin.y+2, 140, Psize.height)];
                [cell.contentView addSubview:positionLabel];

                UIImageView *pointIV = [[UIImageView alloc]initWithFrame:CGRectMake(width_x(actImgV)+10, height_y(positionLabel)+7, 8, 10)];
                pointIV.image = [UIImage imageNamed:@"activity_exhibition"];
                [cell.contentView addSubview:pointIV];//

                joinLabel = [[UILabel alloc]initWithFrame:CGRectMake(posLb.frame.origin.x, height_y(positionLabel)+2, timeLabel.frame.size.width, timeLabel.frame.size.height)];
                joinLabel.font = posLb.font;
                joinLabel.backgroundColor = [UIColor clearColor];
                joinLabel.text = [NSString stringWithFormat:@"参展: %@",artNameStr];//@"参展: 季大纯";
                joinLabel.textColor = TEXTBLACKCOLORE4;
                [cell.contentView addSubview:joinLabel];

            }
            if (!hostLabel) {

                UIImageView *pointIV = [[UIImageView alloc]initWithFrame:CGRectMake(width_x(actImgV)+10, height_y(joinLabel)+5, 7, 10)];
                pointIV.image = [UIImage imageNamed:@"activity_host"];
                [cell.contentView addSubview:pointIV];//
                
                hostLabel = [[UILabel alloc]initWithFrame:CGRectMake(posLb.frame.origin.x, height_y(joinLabel), joinLabel.frame.size.width, joinLabel.frame.size.height)];
                hostLabel.backgroundColor = [UIColor clearColor];
                hostLabel.font = joinLabel.font;
                hostLabel.textColor = TEXTBLACKCOLORE4;
                hostLabel.text = [NSString stringWithFormat:@"主办: %@",activitySponsor];//@"主办: 尤伦斯当代艺术中心UCCA";
                [cell.contentView addSubview:hostLabel];
            }

            if (!designLabel) {
                designLabel = [[UILabel alloc]initWithFrame:CGRectMake(posLb.frame.origin.x, height_y(hostLabel), joinLabel.frame.size.width, joinLabel.frame.size.height)];
                designLabel.backgroundColor = [UIColor clearColor];
                designLabel.font = joinLabel.font;
                designLabel.textColor = TEXTBLACKCOLORE4;
                designLabel.text = [NSString stringWithFormat:@"承办: %@",activityUndertake];//@"策展人: 郑晓俊";
                if ([activityUndertake isEqualToString:@""]) {
                    NSLog(@"cell add designer");
                }else{

                    [cell.contentView addSubview:designLabel];
                }
                

            }

            UIView * lineView = [[UIView alloc] initWithFrame:CGRectMake(0, height_y(actImgV)+10, UI_SCREEN_WIDTH, 1)];
            lineView.backgroundColor = RGBA(219, 219, 219, 1);
            [cell.contentView addSubview:lineView];

            if (!shareBtn) {
                shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                shareBtn.frame = CGRectMake(0, height_y(lineView), UI_SCREEN_WIDTH/2-2, 44);
                shareBtn.backgroundColor = [UIColor clearColor];
                [cell.contentView addSubview:shareBtn];

                UIView *hlineView = [[UIView alloc]initWithFrame:CGRectMake(width_x(shareBtn), height_y(lineView)+5, 1, 34)];
                hlineView.backgroundColor = RGBA(219, 219, 219, 1);
                [cell.contentView addSubview:hlineView];

                UIImageView * scanIV = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"artist_NFav"]];
                scanIV.frame = CGRectMake(UI_SCREEN_WIDTH/4-13, 5, 18, 16);

                scanLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 22, UI_SCREEN_WIDTH/2, 22)];
                scanLabel.backgroundColor = [UIColor clearColor];
                scanLabel.textColor  = TEXTBLACKCOLORE3;
                scanLabel.font = [UIFont systemFontOfSize:11];
                scanLabel.text = [NSString stringWithFormat:@"%@次浏览",activityScanTime];
                scanLabel.textAlignment = NSTextAlignmentCenter;


                scaneBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                scaneBtn.frame = CGRectMake(width_x(hlineView), height_y(lineView), UI_SCREEN_WIDTH/2-2, 44);
                [scaneBtn addTarget:self action:@selector(sharrebtnClick) forControlEvents:UIControlEventTouchUpInside];
                scaneBtn.backgroundColor = [UIColor clearColor];
                [cell.contentView addSubview:scaneBtn];
                [shareBtn addSubview:scanLabel];
                [shareBtn addSubview:scanIV];


                UIImageView * shareIV = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"share_icon"]];
                shareIV.frame = CGRectMake(UI_SCREEN_WIDTH/4-9, 7, 18, 16);

                UILabel *shareLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 22, UI_SCREEN_WIDTH/2, 22)];
                shareLabel.backgroundColor = [UIColor clearColor];
                shareLabel.textColor  = TEXTBLACKCOLORE3;
                shareLabel.font = [UIFont systemFontOfSize:11];
                shareLabel.text = [NSString stringWithFormat:@"分享"];
                shareLabel.textAlignment = NSTextAlignmentCenter;
                
                [scaneBtn addSubview:shareIV];
                [scaneBtn addSubview:shareLabel];


            }


            UIView * lineView2 = [[UIView alloc] initWithFrame:CGRectMake(0, height_y(shareBtn), UI_SCREEN_WIDTH, 1)];
            lineView2.backgroundColor = RGBA(219, 219, 219, 1);
            [cell.contentView addSubview:lineView2];
            
        }else if (indexPath.section==1){
            //活动介绍
           
            if (!contLabel) {
                contLabel = [[UILabel alloc ]init];
                contLabel.backgroundColor = [UIColor clearColor];
                contLabel.font = [UIFont systemFontOfSize:13];
                contLabel.frame = CGRectMake(15, 0, 290, 100);
                contLabel.text = activityIntroduce;
                contLabel.numberOfLines = 4;
//                contLabel.lineBreakMode = NSLineBreakByTruncatingTail;

                [cell.contentView  addSubview:contLabel];
                
                arrowIV = [[UIImageView alloc ]init];
                arrowIV.backgroundColor = [UIColor clearColor];
                arrowIV.frame = CGRectMake(150, height_y(contLabel), 10, 10);
                arrowIV.image = [UIImage imageNamed:@"shaixuan_down"];
                [cell.contentView addSubview:arrowIV];
            }
           
            
//            cell.textLabel.text = activityIntroduce;
//            cell.textLabel.font = [UIFont systemFontOfSize:13];
//            cell.textLabel.numberOfLines = 0;
//            cell.textLabel.lineBreakMode = NSLineBreakByTruncatingTail;
//            NSDictionary * tdic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:13],NSFontAttributeName,nil];
//            CGSize  actualsize =[activityIntroduce boundingRectWithSize:CGSizeMake(300, 200) options:NSStringDrawingUsesLineFragmentOrigin  attributes:tdic context:nil].size;


            
        }else if (indexPath.section == 2){

            static NSString * cellName = @"cell11";
            DetailOrgnizerCell * cell11 = [tableView dequeueReusableCellWithIdentifier:cellName];
            if (cell11 == nil){
                cell11 = [[DetailOrgnizerCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
                cell11.backgroundColor = [UIColor clearColor];
                cell11.selectionStyle = UITableViewCellSelectionStyleNone;
            }

            cell11.ognizerLabel.text = [NSString stringWithFormat:@"参展作品"];// @"参展作品";
//            cell11.ognizerLabel.text = [NSString stringWithFormat:@"参展作品(%@)",exhibitWorkCount];// @"参展作品";
            cell11.ognizerLabel.font = [UIFont systemFontOfSize:17];
//            UIImageView *nextLvIV = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"launh_sure"]];
//            nextLvIV.frame = CGRectMake(290, 20, 15, 20);
//            nextLvIV.backgroundColor = [UIColor clearColor];
//            [cell.contentView addSubview:nextLvIV];
            return cell11;
        }
        return cell;
    }
    return nil;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if (indexPath.section == 1) {
        
        NSDictionary * tdic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:13],NSFontAttributeName,nil];
        CGSize  actualsize =[activityIntroduce boundingRectWithSize:CGSizeMake(290, 200) options:NSStringDrawingUsesLineFragmentOrigin  attributes:tdic context:nil].size;

        isClicked = !isClicked;
        
        if (isClicked) {
            
            varHeight = actualsize.height+20;
            
            contLabel.frame = [XDTools xyAutoSizeOfWidget:contLabel andSize:CGSizeMake(290, 200) andtextFont:13];
            contLabel.numberOfLines = 0;
            
            arrowIV.frame = CGRectMake(150, height_y(contLabel), 10, 10);
            arrowIV.image = [UIImage imageNamed:@"shaixuan_up"];
        }else{
        
            contLabel.frame = CGRectMake(15, 5, 290, 100);
            contLabel.numberOfLines = 4;
            arrowIV.frame = CGRectMake(150, height_y(contLabel), 10, 10);
            arrowIV.image = [UIImage imageNamed:@"shaixuan_down"];
        }
      
        
        [tableView reloadData];
        
        NSLog(@"size.height = %f",varHeight);
        NSLog(@" cmmmmm = %@",activityIntroduce);
        
        
//        NSIndexPath *indexPath=[NSIndexPath indexPathForRow:0 inSection:1];
//        [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
        
    }
    if(indexPath.section == 2){
    
        WaterDetailViewController *waterVC = [[WaterDetailViewController alloc] init];
        waterVC.activityId = self.idStr;
        waterVC.signal = @"3";
       
        [self.navigationController pushViewController:waterVC animated:YES];
        DDLOG(@"跳转到瀑布流");
    }
}

#pragma mark  -------- DataSouceManager------------

- (void)getXmlData
{
   
    
    if ([XDTools NetworkReachable]){
        NSString *body = [NSString stringWithFormat:@" <ActivityDetailById xmlns=\"http://tempuri.org/\">"
                          "<id>%@</id>"
                          "<type>%@</type>"
                          "</ActivityDetailById>",_idStr,_typeStr];
        
        __weak ASIFormDataRequest *request = [XDTools postRequestWithDict:body API:ACTIVITYDETAILBYID];
        [request setCompletionBlock:^{
            [XDTools hideProgress:self.contentView];
            //[XDTools hideProgress:self.contentView];
            NSString *responseString = [request responseString];
            // NSDictionary *tempDic = [XDTools  JSonFromString:responseString];
            DDLOG(@"responseString:%@", responseString);
            
            [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
            int statusCode = [request responseStatusCode];
            NSString *soapAction = [[request requestHeaders] objectForKey:@"SOAPAction"];
            
            NSArray *arraySOAP =[soapAction componentsSeparatedByString:@"/"];
            int count = [arraySOAP count] - 1;
            NSString *methodName = [arraySOAP objectAtIndex:count];
            
            // Use when fetching text data
            NSString *result = nil;
            if (statusCode == 200) {
                //表示正常请求
                result = [SoapXmlParseHelper SoapMessageResultXml:responseString ServiceMethodName:methodName];
                NSDictionary  *responseDict = [XDTools JSonFromString:result];
                if ([[responseDict objectForKey:@"code"] intValue]==0){
                    DDLOG(@"res = %@",responseDict);
                    
                    activityTitle =[NSString stringWithFormat:@"%@",[responseDict valueForKey:@"activityTitle"]];
                    if ([activityTitle isEqualToString:@"<null>"]||[activityTitle isKindOfClass:[NSNull class]]) {
                        activityTitle = @"";
                    }
                    activityTime = [NSString stringWithFormat:@"%@",[responseDict valueForKey:@"activityTime"]];
                    
                    if ([activityTime isEqualToString:@"<null>"]||[activityTime isKindOfClass:[NSNull class]]) {
                        activityTime = @"";
                    }

                    organizer = [NSString stringWithFormat:@"%@",[responseDict valueForKey:@"organizer"]];


                    if ([organizer isEqualToString:@"<null>"]||[organizer isKindOfClass:[NSNull class]]) {
                        organizer = @"";
                    }

                    
                    artNameStr = [NSString stringWithFormat:@"%@",[responseDict valueForKey:@"activityArtName"]];
                    if ([artNameStr isEqualToString:@"<null>"]||[artNameStr isKindOfClass:[NSNull class]]) {
                        artNameStr = @"";
                    }
                    
                    activitySponsor = [NSString stringWithFormat:@"%@",[responseDict valueForKey:@"activityCooperator"]];
                    
                    if ([activitySponsor isEqualToString:@"<null>"]||[activitySponsor isKindOfClass:[NSNull class]]) {
                        activitySponsor = @"尤伦斯当代艺术中心";
                    }
                    activeDesign =[NSString stringWithFormat:@"%@",[responseDict valueForKey:@"activityDesign"]];
                    
                    if ([activeDesign isEqualToString:@"<null>"]||[activeDesign isKindOfClass:[NSNull class]]) {
                        activeDesign = @"郑晓俊";
                    }
                    
                    activityPosition = [NSString stringWithFormat:@"%@",[responseDict valueForKey:@"activityPosition"]];
                    
                    if ([activityPosition isEqualToString:@"<null>"]||[activityPosition isKindOfClass:[NSNull class]]) {
                        activityPosition = @"北京  朝阳  尤伦斯当代\n艺术中心  UCCA 甬道、\n长廊";
                    }
                    
//                    actArray = [responseDict valueForKey:@"activityOrganizationList"];
                    activityIntroduce = [NSString stringWithFormat:@"%@",[responseDict valueForKey:@"activityIntroduce"]];
                    UITableViewCell * cell =(UITableViewCell *)[_detailActTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:1]];
                    
                    CGRect rect = [XDTools xyAutoSizeOfWidget:cell.textLabel andSize:CGSizeMake(280, 30) andtextFont:15];
                    cell.textLabel.frame = CGRectMake(rect.origin.x, rect.origin.y, 280, 30);
                    cell.textLabel.backgroundColor = [UIColor redColor];
                    
                    if ([activityIntroduce isEqualToString:@"<null>"]||[activityIntroduce isKindOfClass:[NSNull class]]) {
                        activityIntroduce = @"";
                    }
                    
                    exhibitWorkCount = [NSString stringWithFormat:@"%@",[responseDict valueForKey:@"exhibitWorkCount"]];
                    if ([exhibitWorkCount isEqualToString:@"<null>"]||[exhibitWorkCount isKindOfClass:[NSNull class]]) {
                        exhibitWorkCount = @"";
                    }
                    
                    activityScanTime = [NSString stringWithFormat:@"%@",[responseDict valueForKey:@"activityScanTime"]];
                    if ([activityScanTime isEqualToString:@"<null>"]||[activityScanTime isKindOfClass:[NSNull class]]) {
                        activityScanTime = @"";
                    }
                    
                    activityUndertake = [NSString stringWithFormat:@"%@",[responseDict valueForKey:@"activityUndertake"]];
                    if ([activityUndertake isEqualToString:@"<null>"]||[activityUndertake isKindOfClass:[NSNull class]]) {
                        activityUndertake = @"";
                    }
                    
                    activityUrl = [NSString stringWithFormat:@"%@",[responseDict valueForKey:@"activityUrl"]];
                    
                    if ([activityUrl isEqualToString:@"<null>"]||[activityUrl isKindOfClass:[NSNull class]]) {
                        activityUrl = @"";
                    }
                    
                    [self initWidget];
                    
//                    [_detailActTableView reloadData];
                    
                    //                    actNameLb.text = activityTitle;
                    //                    timeLabel.text = [NSString stringWithFormat:@"时间:  %@",activityTime];
                    //                    hostLabel.text = [NSString stringWithFormat:@"主办:  %@",activitySponsor];
                    //                    joinLabel.text = [NSString stringWithFormat:@"参展:  %@",artNameStr];
                    //                    designLabel.text =[NSString stringWithFormat:@"策展人:  %@",activeDesign];
                    //                    positionLabel.text =[NSString stringWithFormat:@"%@",activityPosition];
                    
                }else{
                    [self initWidget];
                }
            }
        }];
        
        [request setFailedBlock:^{
            [XDTools hideProgress:self.contentView];
        }];
        
        [request startAsynchronous];
        [XDTools showProgress:self.contentView];
    }else{
        [XDTools showTips:brokenNetwork toView:self.contentView];
    }
    
}

-(void)sharrebtnClick
{
    _shareView.hidden =NO;
}

#pragma mark ================XDShareView Delegate===============
-(void)shareViewBtnCLick:(UIButton *)button
{
    int tag = button.tag - SHAREBTNTAG;
    //设置分享内容和回调对象
    if (tag == 0){
        //微信会话
        [UMSocialData defaultData].extConfig.wxMessageType = UMSocialWXMessageTypeText;
        [[UMSocialControllerService defaultControllerService] setShareText:@"分享到微信－找画APP" shareImage:[UIImage imageNamed:@"Icon"] socialUIDelegate:self];
        [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToWechatSession].snsClickHandler(self,[UMSocialControllerService defaultControllerService],YES);
    }else if (tag == 1){
        //朋友圈分享
        [[UMSocialControllerService defaultControllerService] setShareText:@"分享到朋友圈－找画APP" shareImage:[UIImage imageNamed:@"Icon"] socialUIDelegate:self];
        [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToWechatTimeline].snsClickHandler(self,[UMSocialControllerService defaultControllerService],YES);
    }else if (tag == 2){
        //新浪微博
        [[UMSocialControllerService defaultControllerService] setShareText:@"分享到新浪微博－找画APP" shareImage:[UIImage imageNamed:@"Icon"] socialUIDelegate:self];
        [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToSina].snsClickHandler(self,[UMSocialControllerService defaultControllerService],YES);
    }else if (tag == 3){
        //复制链接地址
        [[UIPasteboard generalPasteboard] setString:activityUrl];
        [XDTools showTips:@"复制成功" toView:_shareView];
    }else if (tag == 4){
        //关闭
        _shareView.hidden =YES;
    }
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
